home *** CD-ROM | disk | FTP | other *** search
/ Wildcat Files 2 / The Wildcat Files 2 (Arsenal Computer).ISO / wildcat / publish.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-23  |  11KB  |  255 lines

  1. unit Publish;
  2.  
  3. {$I WCDEFINE.INC}
  4.  
  5. interface
  6.  
  7. (**************************************************************************
  8. Statistics/configuration & DB record structure for wcPRO version 4.10.
  9. Copyright (c) 1991,95 Mustang Software Inc. All rights reserved.
  10.  
  11. Last Revised : 03/23/95
  12. Revision     : 'A'
  13. Resonsibility: Sam Robertson
  14.  
  15. **************************************************************************)
  16.  
  17. uses
  18.   Dos,
  19.   Filer,
  20. {$IFDEF OPRO}
  21.   OpDate,
  22.   OpString,
  23. {$ELSE}
  24.   TpDate,
  25.   TpString,
  26. {$ENDIF}
  27.   ProErr,  {Error procs in here}
  28.   wcDB,
  29.   wcType;
  30.  
  31. const
  32.   StatHistoryName = 'PROSTAT.HIS';
  33.   BullHistoryName = 'PROSTAT.BUL';
  34.   QuesHistoryName = 'PROSTAT.QUE';
  35.  
  36. const
  37.   MaxNodes = 250;
  38.  
  39. type
  40.   TExtensions = record
  41.                   Ext : String[3];              {Extension}
  42.                   Viewer : DirStr;              {Path and filename to viewer}
  43.                 end;
  44.  
  45. type
  46.   PProConfig = ^TProConfig;  {WCPRO.CFG}
  47.   TProConfig = record
  48.                  WcProDir : DirStr;                         {Location of files}
  49.                  Extensions : array [1..10] of TExtensions; {External viewers configuration}
  50.                  Headers : Boolean;                         {Show headers?}
  51.                  AppendMode : Boolean;                      {Append to existing files?}
  52.                  IgnoreMaintenanceMode : Boolean;           {Ignore status in NodeInfo.dat}
  53.                end;
  54. type
  55.   TStat = (stUser, stFile);
  56.  
  57. type
  58.   {The following file is a BTREE Filer database, see implementation for}
  59.   {Key structure and initialization}
  60.   TStatRecord = record                     {PROSTAT.DAT/IX  Contains top downloads/uploaders/downloaders}
  61.                   Status : LongInt;                     {Filer record}
  62.                   rtype : TStat;                        {Dictates type of record}
  63.                   name : String[25];                    {User name/FileName}
  64.                   downloads : LongInt;                  {Total downloads}
  65.                   uploads : LongInt;                    {Total uploads}
  66.                   FileArea : Word;                      {Total file areas}
  67.                   Filler : String[253];                 {Filler space for future expansion}
  68.                 end;
  69.  
  70. type  {Used in PROSTAT.HIS}
  71.   TProLogOff = (ploNormal, ploDropCarrier, ploNoTime, ploAltMinus, ploNoActivity);
  72.  
  73. const
  74.   LogOffString : array[TProLogOff] of String[12] = ('Normal', 'Drop Carrier',
  75.                                                     'No Time', 'Alt Minus',
  76.                                                     'No Activity');
  77. type
  78.   TAreaCodes = record
  79.                  AC : Word;          {Actual areacode number //SANITY HEADER for sort}
  80.                  Val : LongInt;      {Total number of calls from this AC}
  81.                end;
  82.  
  83. type
  84.   {The following file is stored using OPRO's stream IO routines for}
  85.   {upgradeability.  If you wish to read this as a flat structure,}
  86.   {uncomment the status field}
  87.   PHistory = ^THistory;                                 {PROSTAT.HIS}
  88.   THistory = record
  89. {              StreamVersion    : LongInt       Only uncomment if reading as a standard file}
  90.                StartDate        : DateTimeRec;                   {Start Date & time}
  91.                EndDate          : DateTimeRec;                   {End Date & Time}
  92.                TotalCalls       : array[0..MaxNodes] of LongInt; {Total calls by node number}
  93.                Minutes          : array[0..MaxNodes] of LongInt; {Total minutes by node number}
  94.                Baud             : array[TBaudType] of LongInt;   {Total calls by baud rate}
  95.                BaudMNP          : array[TBaudType] of LongInt;   {Total calls but only Error Correcting connections}
  96.                WeekdayCount     : array[DayType] of LongInt;     {Total calls by day of week}
  97.                HourCount        : array[0..23] of LongInt;       {Total calls by hour of day}
  98.                Logoffs          : array[TproLogOff] of LongInt;  {Total logoffs/calls by how caller hung up}
  99.                Badnames         : LongInt;                       {Total number of badnames}
  100.                WrongPasswords   : LongInt;                       {Total wrong passwords}
  101.                NewUsers         : LongInt;                       {Total new users}
  102.                Newsletter       : LongInt;                       {Total times read newsletter}
  103.                BulletinsRead    : LongInt;                       {Total bulletins read}
  104.                Questionnaires   : LongInt;                       {Total Questionnaires}
  105.                PagedSysop       : LongInt;                       {Total times sysop paged}
  106.                ReadFile         : LongInt;                       {Total times files have been read}
  107.                MessagesLeft     : LongInt;                       {Total messages left}
  108.                DoorsEntered     : LongInt;                       {Total doors entered}
  109.                Uploads          : array[TProtocol] of LongInt;   {Total uploads by protocol}
  110.                Downloads        : array[TProtocol] of LongInt;   {Total downloads by protocol}
  111.                LeechMessage     : LongInt;                       {Total download ratio warnings}
  112.                LeechReject      : LongInt;                       {Total downloads rejected due to ratio}
  113.                TodayLeechCountReject : LongInt;                  {Count download rejections}
  114.                TodayLeechKbyteReject : LongInt;                  {KByte download rejections}
  115.                BirthdatePhone   : LongInt;                       {Total wrong birthdates or Phone}
  116.                DownloadFailures : LongInt;                       {Total download failures}
  117.                BBSErrors        : LongInt;                       {Total BBSErrors}
  118.                MaxConfAreas : Word;  {Need this if conf number changes outside of PRO // SHOULD NOT BE EDITABLE}
  119.                AreaCodes : array[0..1000] of TAreaCodes;         {Areacodes}
  120.                detects : array[TScrnDisplay] of Word;            {Total calls by what WC detected}
  121.              end;
  122.  
  123. const
  124.   scUseHistory       =  $001;
  125.   scEraseLogs        =  $002;
  126.   scMessageTable     =  $004;
  127.   scDownloadGraph    =  $008;
  128.   scUploadGraph      =  $010;
  129.   scBaudGraph        =  $020;
  130.   scLogOffGraph      =  $040;
  131.   scCallsByDayGraph  =  $080;
  132.   scCallsbyHourGraph =  $100;
  133.   scNodeTable        =  $200;
  134.   scGeneralStats     =  $400;
  135.   scAverageUser      =  $800;
  136.   scSysopStuff       = $1000;
  137.   scCreateBaks       = $2000;
  138.  
  139. type  {*.PSC configuration files}
  140.   PStatConfig = ^TStatConfig;
  141.   TStatConfig = record
  142.                      Nodes : TNodeInfoBits;  {Nodes to process}
  143.                      scFlags,                {Flags}
  144.                      BulletinTable,          {Total bulletins to list}
  145.                      QuestionnaireTable,     {Total questionnaires to list}
  146.                      DoorTable,              {Total doors to list}
  147.                      NumAcs,                 {Total AC's to list}
  148.                      FileDownloads,          {Total file downloads to list}
  149.                      UserDownloads,          {Total user downloads to list}
  150.                      UserUploads : Word;     {Total user uploads to list}
  151.                      bbsfile,                {Path to .BBS output file}
  152.                      textfile,               {Path to .TXT output file}
  153.                      RIPfile : DirStr;       {Path to .RIP output file}
  154.                      MaxConfs : Word;        {Sanity header/same as Makewild}
  155.                      MaxFiles : Word;        {"       "      "    "  "}
  156.                    end;
  157.  
  158. {File if Variably size and contains the flags for the bitsets of conferences/
  159.  file areas to process}
  160.  
  161. {
  162. In the questionnaire and bulletin directories there are prostat.bul and
  163. prostat.que files which are simply files of longint for each bulletin.
  164. }
  165.  
  166. const
  167.   StatUserNameKey = 1;
  168.   StatUserDownloadKey = 2;
  169.   StatUserUploadKey = 3;
  170.  
  171.   StatFileNameKey = 1;
  172.   StatFileDownloadKey = 2;
  173.  
  174. type
  175.   {The statistics database descendant of TFileBlock from the wcDB.PAS unit}
  176.   TStatDatabase = object(TFileBlock)
  177.                     constructor Init;
  178.                     procedure GetCreateInfo(var Len : Word; var Keys : Integer; var IID : IsamIndDescr); virtual;
  179.                     function BuildKey(const Data; Key : Integer) : IsamKeyStr; virtual;
  180.                     procedure FatalDBError(const S : String); virtual;
  181.                     procedure LogDBError(const S : String); virtual;
  182.                   end;
  183.  
  184. function BuildStatFileNameKey(Name : String; Area : Word) : IsamKeyStr;
  185.  
  186. var
  187.   ProConfig : PProConfig;
  188.  
  189.  
  190. implementation
  191.  
  192.   constructor TStatDatabase.Init;
  193.   var
  194.     f : file;
  195.     Size : Word;
  196.  
  197.   begin
  198.     if not inherited Init(ProConfig^.wcprodir+'PROSTAT',
  199.                           False,
  200.                           False,
  201.                           StatUserNameKey,
  202.                           SizeOf(TStatRecord)) then
  203.       Fail;
  204.   end;
  205.  
  206.   procedure TStatDataBase.GetCreateInfo(var Len : Word;
  207.                                         var Keys : Integer;
  208.                                         var IID : IsamIndDescr);
  209.   begin
  210.     Len := SizeOf(TStatRecord);
  211.     Keys := 3;
  212.     IID[StatUserNameKey].KeyL := 30;
  213.     IID[StatUserNameKey].AllowDupK := False;
  214.     IID[StatUserDownloadKey].KeyL := 10;
  215.     IID[StatUserDownloadKey].AllowDupK := True;
  216.     IID[StatUserUploadKey].KeyL := 10;
  217.     IID[StatUserUploadKey].AllowDupK := True;
  218.   end;
  219.  
  220.   function TStatDatabase.BuildKey(const Data; Key : Integer) : IsamKeyStr;
  221.   var
  222.     S : TStatRecord absolute Data;
  223.  
  224.   begin
  225.     BuildKey := '';
  226.     case Key of
  227.       StatUserNameKey : if s.rtype = stUser then
  228.                           BuildKey := Chr(Ord(StUser))+StUpCase(S.Name)
  229.                         else
  230.                           BuildKey := Chr(Ord(StFile))+StUpCase(S.Name)+Word2Key(S.FileArea);
  231.       StatUserDownloadKey : BuildKey := Long2Key(S.Downloads);
  232.       StatUserUploadKey : if s.rtype = stUser then
  233.                             BuildKey := Long2Key(s.uploads);
  234.     else
  235.       FatalError('Invalid key number in StatDatabase.  BuildKey: ' + Long2Str(Key));
  236.     end;
  237.   end;
  238.  
  239.   function BuildStatFileNameKey(Name : String; Area : Word) : IsamKeyStr;
  240.   begin
  241.     BuildStatFileNameKey := Chr(Ord(StFile))+StUpCase(Name)+Word2Key(Area);
  242.   end;
  243.  
  244.   procedure TStatDatabase.FatalDBError(const S : String);
  245.   begin
  246.     ProErr.LogBtreeError('PROSTAT DATABASE: '+S, IsamError);
  247.   end;
  248.  
  249.  
  250.   procedure TStatDatabase.LogDBError(const S : String);
  251.   begin
  252.     ProErr.LogError('PROSTAT DATABASE: '+S);
  253.   end;
  254.  
  255. end.